package com.fjec.devops.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjec.common.annotation.OpeLog;
import com.fjec.common.protocol.JsonResult;
import com.fjec.devops.service.IBizExchangeGiftExcelService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
import java.util.Map;

/**
 * <p>
 * 012.礼物兑换Excel下载表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2020-12-08
 */
@RestController
@RequestMapping("/")
public class BizExchangeGiftExcelController {

    @Resource
    private IBizExchangeGiftExcelService service;

    /**
     * 用户兑换礼物数据列表
     *
     * @param page
     * @param searchBy
     * @param condition
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("/y/user/gift/exchange/page")
    public JsonResult getExchangeGiftPage(Page page,
                                          @RequestParam Integer searchBy,
                                          @RequestParam(value = "shopName", required = false) String condition,
                                          @RequestParam(required = false) String startTime,
                                          @RequestParam(required = false) String endTime) {
        return service.getExchangeGiftPage(page, searchBy, condition, startTime, endTime);
    }

    /**
     * 分页获取用户兑换礼物数据列表
     *
     * @param page
     * @return
     * @throws Exception
     */
    @GetMapping("/y/user/gift/exchange/excel/page")
    public JsonResult getEntityListPage(Page page) throws Exception {
        return service.getEntityListPage(page);
    }

    /**
     * 下载用户兑换礼物数据列表excel
     *
     * @param id         进件数据id
     * @param downloadId 下载文件Id
     * @param res
     * @throws Exception
     */
    @OpeLog(desc = "下载用户兑换礼物数据列表excel")
    @GetMapping("/y/download/user/gift/exchange/excel")
    public void downloadExcel(@RequestParam Long id,
                              @RequestParam Long downloadId,
                              HttpServletResponse res) throws Exception {
        service.downloadExcel(id, downloadId, res);
    }

}
